<?php 
$conn = oci_connect("gaurav", "gaurav", "xe"); 
$msg='holaaaa!';
$from='xw2174';
$to='gip2103';


$query = "INSERT INTO Messages(MessageID,Mesg,FromCuid,ToCuid) VALUES(msgseq.NEXTVAL,:mesg,:fromcuid,:tocuid)";

$bindargs = array();
array_push($bindargs, array('MESG', $msg, -1));
array_push($bindargs, array('FROMCUID', $from, -1));
array_push($bindargs, array('TOCUID', $to, -1));

$r = db_execute_statement($conn, $query, $bindargs);


function db_execute_statement($conn, $statement, $bindvars = array())
{
  $stid = oci_parse($conn, $statement);
  if (!$stid) {
    db_error($conn, __FILE__, __LINE__);
  }
    // Bind parameters
  foreach ($bindvars as $b) {
    // create local variable with caller specified bind value 
    $$b[0] = $b[1];
    $r = oci_bind_by_name($stid, ":$b[0]", $$b[0], $b[2]);
    if (!$r) {
      db_error($stid, __FILE__, __LINE__);
    }
  }

  $r = oci_execute($stid);
  if (!$r) {
    db_error($stid, __FILE__, __LINE__);
  }
  return($r);
}


?>